package work823;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class work7ClentThread extends Thread {
  private Socket s;
  private int id;


  public work7ClentThread(Socket s, int id) {
    this.s = s;
    this.id = id;
  }

  @Override
  public void run() {
    try {
      Scanner sc = new Scanner(System.in);
      OutputStream os = s.getOutputStream();
      InputStream is = s.getInputStream();
      BufferedReader br = new BufferedReader(new InputStreamReader(is));
      BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os));
      while (true) {
        String str = id+":\t" + sc.next();
        bw.write(str);
        bw.flush();
        bw.newLine();
        bw.write("");
        bw.flush();
//        String str2;
//        while ((str2 = br.readLine()) != null) {
//          System.out.println(str2);
//          s.shutdownInput();
//      }
//        s.shutdownOutput();
      }
    }catch (Exception e){
      e.printStackTrace();
    }finally {
      try {
        s.shutdownOutput();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
}
